package cn.itcast.order.controller;

import cn.itcast.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
@RefreshScope//刷新配置
public class OrderController {
    @Value("${spring.datasource.username}")//加载配置文件中的配置项
    private String name;
    @Autowired
    private OrderService orderService;
    @RequestMapping(value="/{id}",method = RequestMethod.GET)
    public String findById(@PathVariable("id") String id){
        System.out.println("订单服务（端口号9002）被调用...username=" + name);
        return orderService.findById(id);
    }
}